import {
  addResizeListener,
  removeResizeListener
} from 'element-ui/lib/utils/resize-event';
import { debounce } from '@/utils/util';
export default {
  data() {
    return {
      proxySetBodyStyle: null,
      mPanelFit: true,
      mLayoutFix: true,
      mLayoutStyle: ''
    };
  },
  methods: {
    responseStyle() {
      let clientWidth = document.body.clientWidth;
      this.mPanelFit = clientWidth > 1366;
      this.mLayoutFix = clientWidth > 1366;
      this.mLayoutStyle = clientWidth > 1366 ? '' : 'display:block;';
    }
  },
  created() {
    this.proxySetBodyStyle = debounce(this.responseStyle, 100, false, this);
  },
  mounted() {
    this.responseStyle();
    addResizeListener(document.body, this.proxySetBodyStyle);
  },
  beforeDestroy() {
    removeResizeListener(document.body, this.proxySetBodyStyle);
  }
};
